package futbol.tacticas.concursantes.qualitycode.opponent;

import java.util.ArrayList;
import java.util.List;

import futbol.tacticas.concursantes.qualitycode.QCodeTactica;
import futbol.tacticas.concursantes.qualitycode.common.QBall;
import futbol.tacticas.concursantes.qualitycode.common.QPlayer;
import futbol.tacticas.concursantes.qualitycode.common.QTeam;

public class QOpponentTeam extends QTeam<QOpponentPlayer>
{
  public static final int ATACANDO = 60;
  
  public QOpponentTeam(String ID)
  {
    super(ID);
    for (int i = 0; i < QCodeTactica.TEAM_SIZE; i++)
      players.add(new QOpponentPlayer(i));
  }
 
  public List<QPlayer> atacando()
  {
    final List<QPlayer> atacando = new ArrayList<QPlayer>();
    
    for (QPlayer player : players)
    {
      if (player.getX() <= ATACANDO)
        atacando.add(player);
    }
    
    return atacando;
  }

  public int turnosInterseptor(List<QBall> balls)
  {
    int turnos = getPlayer(0).turnosInterseptarBola(balls);
    for (int i = 1; i < players.size(); i++)
    {
      final int turnos2 = getPlayer(i).turnosInterseptarBola(balls);        
      if (turnos > turnos2)
        turnos = turnos2;
    }
    return turnos;
  }
}
